namespace MovieTheater.Data.Migrations
{
    using Microsoft.AspNet.Identity;
    using Microsoft.AspNet.Identity.EntityFramework;
    using MovieTheater.Data.Models;
    using System;
    using System.Data.Entity;
    using System.Data.Entity.Migrations;
    using System.Linq;

    internal sealed class Configuration : DbMigrationsConfiguration<MovieTheater.Data.MoviesDbContext>
    {
        public Configuration()
        {
            AutomaticMigrationsEnabled = false;
        }

        protected override void Seed(MovieTheater.Data.MoviesDbContext context)
        {
            UserStore<User> store = new UserStore<User>(context);
            UserManager<User> manager = new UserManager<User>(store);

            manager.Create(new User
            {
                UserName = "Nick"
            });

            var u1 = manager.FindByName("Nick");

            context.Movies.AddOrUpdate(m => m.Name,
                new Movie { Name = "Star Wars", PosterUrl = "http://www.filmmusicnotes.com/wp-content/uploads/2013/03/star-wars-poster.jpg", Rating = 5, User = u1 },
                new Movie { Name = "Tombstone", PosterUrl = "http://www.movieposter.com/posters/archive/main/15/A70-7548", Rating = 5, User = u1 },
                new Movie { Name = "X-Men: The Last Stand", PosterUrl = "http://farm4.staticflickr.com/3215/3018500752_946479ee9e.jpg", Rating = 2, User = u1 }
            );
        }
    }
}
